 package io.gitee.caoxiaoyu97.log4j.defender.replacer;
 
 import org.springframework.util.StringUtils;
 public class ReplaceStrategy
 {
   private Integer remainPrefix;
   private Integer remainSuffix;
   private String markValue;
   private boolean isReplaceFull;
   
   public ReplaceStrategy(Integer remainPrefix, Integer remainSuffix, String markValue) {
     this.remainPrefix = remainPrefix;
     this.remainSuffix = remainSuffix;
     this.markValue = markValue;
     this.isReplaceFull = (remainPrefix.intValue() == 0 && remainSuffix.intValue() == 0);
   }
 
   
   public String doMark(String input) {
     if (this.isReplaceFull || isRemainInvalid(input)) {
       return this.markValue;
     }
     return (new StringBuilder(input))
       .replace(this.remainPrefix.intValue(), input.length() - this.remainSuffix.intValue(), this.markValue)
       .toString();
   }
   
   protected boolean isRemainInvalid(String input) {
     return (StringUtils.isEmpty(input) || input.length() - this.remainSuffix.intValue() <= this.remainPrefix.intValue());
   }
 }
